<template>
  <!--卡位管理  发送的短信 -->
  <div class="app-container ">
    <div class="" v-loading="loading">
      <el-form :model="queryParams" ref="queryForm" :inline="true" class="zdy-form search-form-new" label-width="100px">
        <el-form-item label="卡位类型" prop="dataType">
          <el-select v-model="queryParams.dataType" placeholder="请选择" @change="search">
            <el-option label="我的卡位" :value="1" />
            <el-option label="我使用的" :value="2" />
            <el-option label="我管理的" :value="3" v-if="checkPermi(['phoneManage:chuzude'])"/>
          </el-select>
        </el-form-item>
        
        <el-form-item label="游戏运营商" prop="gameCarrierId">
          <el-select v-model="queryParams.gameCarrierId" placeholder="请选择游戏运营商" clearable>
            <el-option v-for="dict in carrierTypes" :key="dict.id" :label="dict.name" :value="dict.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="发送状态" prop="sendState">
          <el-select v-model="queryParams.sendState" placeholder="请选择" clearable>
            <el-option label="成功" :value="1" />
            <el-option label="失败" :value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="发送人" prop="createName">
          <el-input placeholder="请输入昵称" v-model="queryParams.createName" clearable></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="sendTel">
              <el-input v-model="queryParams.sendTel" placeholder="请输入手机号" clearable size="small" />
            </el-form-item>
        <el-form-item label="时间" prop="timer">
          <el-date-picker v-model="timer" type="daterange" range-separator="至" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期" clearable>
          </el-date-picker>
        </el-form-item>
        
        <el-form-item class="btns">
          <el-button type="primary" icon="el-icon-search" @click="search" class="zdy-btn">搜索</el-button>
          <el-button type="warning" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <div class="table_box">
        <el-table stripe :data="tableData.records">
          <el-table-column prop="id" label="序号" width="80"></el-table-column>
          <el-table-column prop="sendTel" label="手机号" ></el-table-column>
          <el-table-column prop="toNum" label="接收号码" ></el-table-column>
          <el-table-column prop="createTime" label="时间" ></el-table-column>
          <el-table-column prop="gameCarrierName" label="游戏运营商"></el-table-column>
          <el-table-column prop="" label="状态">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.sendState==1" type="success">成功</el-tag>
              <el-tag v-if="scope.row.sendState==2" type="danger">失败</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="content" label="短信内容"></el-table-column>
          <el-table-column prop="fasongTenantName" label="发送方"></el-table-column>
          <el-table-column prop="createName" label="发送人"></el-table-column>
          <el-table-column prop="res" label="返回结果"></el-table-column>
        </el-table>
        <pagination v-show="tableData.total > 0" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
      </div>
    </div>
 
  </div>
</template>

<script>
import phoneApi from "@/api/phoneManage";
export default {
  name: "",
  // components: { addDialog },
  data() {
    return {
      timer: [],
      tableData: {
        records: [],
        total: 0,
      },
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        dataType:1
      },
    };
  },
  created() {
    this.getList();
  },
  activated() {},
  computed:{
    carrierTypes(){
      return this.$store.getters.gameYunyingshangList
    }
  },
  methods: {
    // 获取列表
    getList() {
      this.loading = true;
      if (this.timer && this.timer.length) {
        this.queryParams.createTimeStart = this.timer[0] + " 00:00:00";
        this.queryParams.createTimeEnd = this.timer[1] + " 23:59:59";
      } else {
        this.queryParams.createTimeStart = "";
        this.queryParams.createTimeEnd = "";
      }
      phoneApi.telManageSendRecordlist(this.queryParams).then((response) => {
        this.tableData.records = response.rows;
        this.tableData.total = response.total;
        this.loading = false;
      });
    },
    copy(txt) {
      this.$copyText(txt).then((res) => {
        this.$message.success("已复制到剪切板");
      });
    },
    // 搜索
    search() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    //重置
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        dataType:this.queryParams.dataType
      };
      this.timer = [];
      this.getList();
    },
  },
};
</script>
<style lang="scss" scoped>
.tips{
  font-size: 16px;
  margin-bottom: 10px;
  color: red;
}
.link-box {
  > div {
    text-align: center;
    margin-bottom: 10px;
  }
  .mylink {
    margin-right: 10px;
    a {
      color: $primary;
    }
  }
}
</style>